package top.soulblack.purchasesale.mapper.system;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import top.soulblack.purchasesale.model.SystemAnnounce;
import top.soulblack.purchasesale.model.VO.AnnounceVO;

import java.util.List;

/**
 * create by 小川
 */
@Mapper
public interface AnnounceMapper {

    int deleteById(Integer id);

    int insert(SystemAnnounce record);

    int insertSelective(SystemAnnounce record);

    SystemAnnounce selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(SystemAnnounce record);

    int updateByPrimaryKey(SystemAnnounce record);

    List<AnnounceVO> selectRole();

    @Select("select * from system_announce")
    List<SystemAnnounce> selectAll();

    @Select("select * from system_announce where title = #{title}")
    List<SystemAnnounce> selectForTitle(@Param("title") String title);

    @Insert("insert into system_announce (title, role, `content`, status, create_time, img_url) values (#{title}, #{role}, #{content}, #{status}, #{createTime} ,#{imgUrl})")
    void addAnnounce(SystemAnnounce systemAnnounce);

    @Select("select count(*) from system_announce where title = #{title}")
    int existAnnounce(String name);

}
